<template>
  <div class="footCont">
    <div
      @click="footfn(item)"
      :class="$route.path == item.url ? 'footItem_active' : 'footItem'"
      :key="index"
      v-for="(item, index) in footArr"
    >
      <div :class="'iconfont ' + item.icon"></div>
      <div class="footVal">{{ item.val }}</div>
      <div v-if="item.msg && showMsgCount > 0" class="msgIcon"></div>
    </div>
  </div>
</template>

<script>
import { getMessageCount } from "@/http/api";

export default {
  components: {},
  data() {
    return {
      showMsgCount: 0,
      footArr: [
        {
          url: "/home",
          val: "大厅",
          icon: "icon-shebeikaifa",
          active: false,
        },
        {
          url: "/order",
          val: "记录",
          icon: "icon-dingdanjilu2",
          active: false,
        },
        {
          url: "/msg",
          val: "消息",
          icon: "icon-xiaoxi3",
          active: false,
          msg: true,
        },
        {
          url: "/user",
          val: "我的",
          icon: "icon-xiaolian",
          active: true,
        },
      ],
    };
  },
  props: {},
  methods: {
    footfn(item) {
      this.$router.replace({ path: item.url });
    },
    getMsg() {
      getMessageCount().then((res) => {
        if (res.data.code == 1) {
          this.showMsgCount = res.data.data;
        }
      });
    },
  },
  mounted() {},
  created() {
    this.getMsg();
  },
};
</script>

<style scoped lang="less">
.footCont {
  width: 100%;
  position: fixed;
  left: 0;
  height: 65px;
  z-index: 102;
  bottom: -1px;
  background-color: #fff;
  // border-top: 1px solid #ebebeb;
  // box-shadow: 0 -0.1rem 0.5rem #ebebeb;
  display: flex;
  justify-content: space-between;
  .footItem,
  .footItem_active {
    width: 50%;
    height: 3rem;
    display: flex;
    align-items: center;
    flex-direction: column;
    color: #999;
    justify-content: center;
    position: relative;
    .msgIcon {
      font-size: 0.6rem;
      position: absolute;
      right: 1.35rem;
      top: 0.45rem;
      padding: 0.2rem;
      box-sizing: border-box;
      background-color: #ff5757;
      color: #fff;
      border-radius: 2rem;
    }
    .iconfont {
      font-size: 1.1rem;
    }
    .footVal {
      font-size: 0.6rem;
      margin-top: 0.1rem;
    }
  }
  .footItem_active {
    color: #86a9fb;
  }
}
</style>
